package com.zhouheng.module.multipledatasource.slave.controller;


import com.zhouheng.module.multipledatasource.slave.dao.SlaveMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * slaveController
 * 测试多数据源切换，跳过service层
 *
 * @author 周恒
 * @date 20180830 16:24:47
 * @since v1.0
 */
@RestController
@RequestMapping("/slave")
public class slaveController {

    private static final Logger LOGGER = LoggerFactory.getLogger(slaveController.class);

    private SlaveMapper slaveMapper;

    public slaveController(SlaveMapper slaveMapper) {
        this.slaveMapper = slaveMapper;
    }

    @RequestMapping("/query")
    public String getSlave(){
        String result = slaveMapper.selectByPrimaryKey(1).toString();
        LOGGER.info("查询slave,result=[{}]",result);
        return result;
    }

}
